﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using JXT.PrimaryKey.Batman.Collections;
using JXT.PrimaryKey.Batman.Domain.Services;
using JXT.PrimaryKey.Batman.Domain.Specifications;
using JXT.PrimaryKey.Batman.Domain.VirtualExchange.Models;
using JXT.PrimaryKey.Batman.Domain.Quotation.Models;

namespace JXT.PrimaryKey.Batman.Domain.VirtualExchange.Services
{
    public interface IUserTransactionDetailService : ICachedService
    {
        void Add(UserTransactionDetail entity);

        void Add(IEnumerable<UserTransactionDetail> source, Action<TaskExecutedStatus> updateAction = null);

        void Delete(UserTransactionDetail entity);

        int Count(ISpecification<UserTransactionDetail> specification);

        UserTransactionDetail GetSingle(int id);

        UserTransactionDetail GetSingle(ISpecification<UserTransactionDetail> specification);

        IPagedCollection<UserTransactionDetail> GetList(IPagedSpecification<UserTransactionDetail> specification);

        /// <summary>
        /// 收益排行
        /// </summary>
        /// <param name="pageSize">每页大小</param>
        /// <param name="pageIndex">页码</param>
        /// <param name="typeId">账号类型Id</param>
        /// <param name="rankCountType">收益类型(日收益，周收益)</param>
        /// <returns>根据收益排好序的UserTransactionDetail对象集合</returns>
        IEnumerable<UserTransactionDetail> GetListByProfit(int pageSize, int pageIndex, int typeId, RankCountType rankCountType = RankCountType.Unknown);

        /// <summary>
        /// 查询收益的总的记录数
        /// </summary>
        /// <param name="typeId"账号类型ID></param>
        /// <param name="rankCountType">收益类型(日，周收益)</param>
        /// <returns></returns>
        int GetCountByProfit(int typeId, RankCountType rankCountType = RankCountType.Unknown);

        /// <summary>
        /// 交易额排行
        /// </summary>
        /// <param name="pageSize">每页大小</param>
        /// <param name="pageIndex">页码</param>
        /// <param name="typeId">账号类型Id</param>
        /// <returns>根据交易额排好序的UserTransactionDetail</returns>
        IEnumerable<UserTransactionDetail> GetListByTurnover(int pageSize, int pageIndex, int typeId);

        /// <summary>
        /// 查询用户最新一期的交易信息
        /// </summary>
        /// <param name="userId">用户id</param>
        /// <param name="typeId">账号类型id</param>
        /// <param name="counttype">收益类型(日，周)</param>
        /// <returns>交易信息</returns>
        TransactionDetailSequence GetLastDateTranscationInfo(int userId, int typeId);

        /// <summary>
        /// 查询某个时间段的日交易信息
        /// </summary>
        /// <param name="userId">用户id</param>
        /// <param name="typeId">绑定类型id</param>
        /// <param name="startTime">开始时间</param>
        /// <param name="endTime">结束时间</param>
        /// <returns></returns>
        IEnumerable<UserTransactionDetail> GetList(int userId, int typeId, DateTime startTime, DateTime endTime);

        /// <summary>
        /// 获取给定时间前的第一条日交易统计记录
        /// </summary>
        /// <param name="userId">用户id</param>
        /// <param name="typeId">类型id</param>
        /// <param name="time">时间</param>
        /// <param name="type">统计类型</param>
        /// <returns></returns>
        UserTransactionDetail GetLastSingle(int userId, int typeId, DateTime time, RankCountType type);

        /// <summary>
        /// 获取给定时间内或者之前的第一条日交易统计记录
        /// </summary>
        /// <param name="userId">用户id</param>
        /// <param name="typeId">类型id</param>
        /// <param name="time">时间</param>
        /// <param name="type">统计类型</param>
        /// <returns></returns>
        UserTransactionDetail GetCurrentOrLastSingle(int userId, int typeId, DateTime time, RankCountType type);

        /// <summary>
        /// 根据条件查询单条记录
        /// </summary>
        /// <param name="userId">用户id</param>
        /// <param name="typeId">绑定类型id</param>
        /// <param name="dt">时间</param>
        /// <param name="mark">sql语句的表示如:(<,<=)</param>
        /// <param name="rankCountType">日，周数据类型</param>
        /// <returns>UserTransactionDetai对象</returns>
        //UserTransactionDetail GetTransactionDetailSingle(int userId, int typeId, DateTime dt, string mark, RankCountType rankCountType);
    }
}
